import dva from 'dva';
import './index.less';
import createLoading from 'dva-loading';
import { Toast } from 'antd-mobile';
// import {browserHistory} from 'dva/router';
import createHistory from 'history/createBrowserHistory';
import appModel from './models/app/appModel';

import "babel-polyfill";
import  FastClick  from './fastclick';
FastClick.attach(document.body);
//console.log(FastClick);
//import createHistory from 'history/createHashHistory';

//import { persistState } from 'redux-devtools'; //生产版本是要把devtool注释掉。
//import DevTools from './utils/DevTools'; //生产版本是要把devtool注释掉。

// 1. Initialize
const app = dva({
  history: createHistory(),
  onError(e) {
    // Toast.fail(e.message);
  },
});

// 2. Plugins
app.use(createLoading({ effects: true }));

app.model(appModel);
// 3.Model
// app.model(require("./models/Home"));
// app.model(require("./models/Login"));
// if (TOOL === "DEV") {
//   app.use({
//     extraEnhancers: [
//       DevTools.instrument(),
//       persistState(window.location.href.match(/[?&]debug_session=([^&#]+)\b/))],
//   });
// }


// 4. Router
app.router(require('./rootRouter'));

// 5. Start
app.start('#root');
